#pragma once

#include <memory>
#include <vector>
#include <stdexcept>
#include <glm\glm.hpp>

#include "BuilderHelper.h"
#include "Algoritmo1D.h"


class SurfaceRevolution {
public:
	SurfaceRevolution(std::unique_ptr<Algoritmo1D> ptrAlg);
	~SurfaceRevolution();

	void init(std::vector<glm::vec3> ptsControl, glm::vec3 ejeRevolucion);
	void build(unsigned int divAngular, unsigned int cantDivisionesCurva);

	std::vector<glm::vec3> getVertices() const;
	std::vector<unsigned int> getIndexBuffer() const;
	std::vector<glm::vec3> getNormales() const;
	std::vector<glm::vec2> getCoordsTextura() const;

private:
	// De aca salen los puntos de la superficie
	std::unique_ptr<Algoritmo1D> m_generadorPts;

	glm::dvec3 m_ejeRevolucion;
	std::vector<glm::vec3> m_vertices;
	std::vector<glm::vec3> m_normales;
	std::vector<glm::vec2> m_coordsTextura;
	std::vector<unsigned int> m_indexBuffer;

	BuilderHelper m_helper;
	std::vector<glm::vec3> buildCurva(unsigned int cantDivisionesCurva) const;
	std::vector<glm::vec3> buildVertices(unsigned int divAngular, unsigned int cantDivisionesCurva) const;
};

